#ifndef MUSIC_DIALOG_H
#define MUSIC_DIALOG_H

#include <QDialog>
#include <QNetworkAccessManager>
#include <QNetworkReply>
#include "my_music.h"
#include "music_json.h"
#include "music_lyricparser.h"


namespace Ui {
class music_dialog;
}

class music_dialog : public QDialog
{
    Q_OBJECT
    
public:
    explicit music_dialog(QWidget *parent = nullptr);
    ~music_dialog();
    

    
private slots:
    void on_Button_play_pause_clicked();
    void on_Button_pervious_clicked();
    void on_Button_next_clicked();
    void onVolumeChanged(int volume);
    void onPositionChanged(qint64 position);
    void onDurationChanged(qint64 duration);
    void onSliderMoved(int position);
    void onMediaStatusChanged(QMediaPlayer::MediaStatus status);
    void onCurrentIndexChanged(int position);
    void updateLyrics();
    
    
    
    
private:
    Ui::music_dialog *ui;
    My_music * m_music;
    Music_Json *m_jsonparser;
    music_lyricparser *m_lyricParser;
    QTimer *m_lyricTimer;
    QVector<SongInfo> songs;
    QList<LrcLine> m_currentLyrics;
    QNetworkAccessManager *m_networkManager;
    
    void fetchLyricsFromNetEase(qint64 songId);
    void loadSongs();
    void updateSongInfo(int index);
    void loadLyrics(int index);
    
    
};


#endif // MUSIC_DIALOG_H
